##################################################
## Author: Stephanie L. DeMora (1), Jennifer L. Merolla (1), Brian Newman (2), and Elizabeth J. Zechmeister (3)
## Project: "Reducing Mask Resistance with Value Consistent Messages: A Study of White Evangelical Christians"
## Purpose: Inital Cleaning for Replication File for Figures and Tables
## Date: Feb 19th 2021
##################################################

df$Exp3_recode <- car::recode(as.numeric(as.character(df$Exp3)), "1 = 'Control'; 2:3 = 'Moral'; 4 = 'Patriotism'; else = NA")
df$Exp3_recode_original <- car::recode(as.numeric(as.character(df$Exp3)), "1 = 'Control'; 2 = 'Without Source'; 3 = 'With Source'; 4 = 'Patriotism'; else = NA")

df$D4_recode <- car::recode(as.numeric(as.character(df$D4)), "1 = '1-Very likely'; 2 = '2-Likely'; 3 = '3-Unlikely'; 4 = '4-Very unlikely'; else = NA")
df$D4_recode2 <- car::recode(as.numeric(as.character(df$D4)), "1 = 4; 2 = 3; 3 = 2; 4 = 1; else = NA")

df$D5_recode <- as.numeric(as.character(df$d5_scale))
df$D5_recode <- car::recode(df$D5_recode, "97 = NA")
df$D5_recode2 <- as.numeric(as.character(df$D5_recode))

df$D6_recode <- car::recode(as.numeric(as.character(df$D6)), "1 = '1-President Trump should always wear...'; 2 = '2-President Trump should sometimes wear...'; 3 = '3-President Trump should never where...'; else = NA")
df$D6_recode2 <- car::recode(as.numeric(as.character(df$D6)), "1 = 1; 2 = 0.5; 3 = 0; else = NA")

df$D7a_recode <- car::recode(as.numeric(as.character(df$D7a)), "1 = 'Yes'; 2 = 'No'; else = NA")
df$D7b_recode <- car::recode(as.numeric(as.character(df$D7b)), "1 = 'Yes'; 2 = 'No'; else = NA")
df$D7c_recode <- car::recode(as.numeric(as.character(df$D7c)), "1 = 'Yes'; 2 = 'No'; else = NA")

df %>%
  mutate(messages = fct_relevel(df$Exp3_recode, "Control")) -> df

df %>%
  mutate(messages2 = fct_relevel(df$messages, "Moral")) -> df

df$pew_bornagain_recode <- car::recode(as.numeric(as.character(df$pew_bornagain)), "1 = 'Yes'; 2 = 'No'; else = NA")

df$pid_recode <- car::recode(as.numeric(as.character(df$pid3)), "1 = 'Democrat'; 2 = 'Republican'; 3 = 'Independent'; 4 = 'Other'; else = NA")

df$pid7_recode <- car::recode(as.numeric(as.character(df$pid7)), "1= '1-Strong Democrat'; 2 = '2-Not very strong Democrat'; 3 = '3-Lean Democrat'; 4 = '4-Independent'; 5 = '5-Lean Republican'; 6 = '6-Not very strong Republican'; 7 = '7-Strong Republican'; else = NA")

df$democrat <- car::recode(as.numeric(as.character(df$pid7)), "1:3 = 1; 5:7 = 0; else = NA")
df$democrat_nolean <- car::recode(as.numeric(as.character(df$pid7)), "1:2 = 1; 6:7 = 0; else = NA")

df$pid7_recode <- car::recode(as.numeric(as.character(df$pid7)), "1 = 1; 2 = 2; 3 = 3; 4 = 4; 5 = 5; 6 = 6; 7 = 7; else = NA")

df$dx_scale_recode <- car::recode(as.numeric(as.character(df$dx_scale)), "97 = NA")

df$D7a_recode2 <- car::recode(as.numeric(as.character(df$D7a)), "1 = 1; 2 = 0; else = NA")
df$D7b_recode2 <- car::recode(as.numeric(as.character(df$D7b)), "1 = 1; 2 = 0; else = NA")
df$D7c_recode2 <- car::recode(as.numeric(as.character(df$D7c)), "1 = 1; 2 = 0; else = NA")

df %>%
  unite(D7_Combine, D7a_recode2:D7c_recode2, na.rm = TRUE, remove = FALSE) -> df

df$D7_Combine <- as.numeric(as.character(df$D7_Combine))

df$attend_recode <- car::recode(as.numeric(as.character(df$R5)), "1 = 5; 2 = 4; 3 = 3; 4 = 2; 5 = 1; else = NA")

df$age <- 2021-df$birthyr

df$age_recode <- car::recode(as.numeric(as.character(df$age)), "1:17 = '1:17'; 18:39 = '18:39'; 40:59 = '40:59'; 60:79 = '60:79'; 79:1000 = '79 or above'; else = NA")

df$gender_recode <- car::recode(as.numeric(as.character(df$gender)), "1 = 'Male'; 2 = 'Female'; else = NA")

df$pid_recode <- car::recode(as.numeric(as.character(df$pid3)), "1 = 'Democrat'; 2 = 'Republican'; 3:4 = 'Independent or Other'; else = NA")

df$educ_recode <- car::recode(as.numeric(as.character(df$educ)), "1 = '1-No HS'; 2 = '2-HS'; 3 = '3-Some College'; 4 = '4-2 year'; 5 = '5-4 year'; 6 = '6-Post Grad'; else = NA")


df <- subset(df,df$race9_1 != 2)

